#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include "myhttp.h"
#include <QtScript>
static int user_password_flag = 0;       //密码错误次数标志
static bool the_flage_of_shut_pushbuyyon = true;                //快捷键标志位
static Dog_information dog;
static User_Login_Infor user;
static Food_information food;
static int food1=0,food2=0,food3=0,food4=0,food5=0,food6=0,food7=0,food8=0,money=0,hea=0,eng=0;
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    this->setWindowTitle("My_Dog_Client");                      //设置程序显示名字
    this->setWindowIcon(QIcon(":/logo/Images/Dog_logo.png"));   //设置程序图标
    this->setWindowFlags(Qt::FramelessWindowHint);//隐藏边框
    ui->label->setStyleSheet("border-image:url(:/Main/Images/BackGround/Main_back.png)");               //设置住背景
    ui->pushButton_Mini->setStyleSheet("QPushButton{border-image:url(:/Main/Images/Main/mini.png);}QPushButton:hover{border-image:url(:/Main/Images/Main/minion.png);}QPushButton:pressed{border-image:url(:/Main/Images/Main/mini.png);}");            //设置迷你按钮样式表
    ui->pushButton_close->setStyleSheet("QPushButton{border-image:url(:/Main/Images/Main/close.png);}QPushButton:hover{border-image:url(:/Main/Images/Main/closeon.png);}QPushButton:pressed{border-image:url(:/Main/Images/Main/close.png);}");        //设置关闭按钮样式表
    ui->widget->move(790,80);                          //移动位置
    ui->pushButton_close->setToolTip("关闭程序");           //设置按钮提示信息
    ui->pushButton_Mini->setToolTip("最小化窗口");               //设置按钮提示信息
    //变量初始化部分
    succeed_login_Flag = false;         //登录成功标志初始化
    user_regist = NULL;                 //用户注册界面类变量初始化
    Retrieve_Password_Dialog = NULL;    //用户找回密码变量初始化
    pushButton_set_up = NULL;           //设置按钮初始化
    pushButton_shop = NULL;             //商店按钮初始化
    book = NULL;                        //读书初始化
    danci = NULL;                           //被单词初始化
    pushButton_AboutUs = NULL;              //关于我们按钮初始化
    about_Us = NULL;                        //关于我们界面初始化
    pushButton_Pack = NULL;                 //背包按钮初始化
    shop = NULL;                    //商店初始化
    pack = NULL;                    //背包初始化
    dog_Movie = NULL;               //Dog动画初始化
    lineEdit_User_Name =new QLineEdit(this);                    //新建用户登录用户名
    lineEdit_User_Name->setMaximumWidth(120);                   //设置最大宽度
    lineEdit_User_Name->setMaximumHeight(22);                   //设置最大高度
    lineEdit_User_Name->setPlaceholderText("请输入用户名");       //设置默认提示文字
    lineEdit_User_Name->setMaxLength(45);                       //设置名字长度
    ui->statusBar->addWidget(lineEdit_User_Name);               //将登录用户名输入框添加到状态栏
    lineEdit_User_Password =new QLineEdit(this);                //新建用户密码输入框
    lineEdit_User_Password->setMaximumWidth(120);               //设置最大宽度
    lineEdit_User_Password->setMaximumHeight(22);               //设置最大高度
    lineEdit_User_Password->setPlaceholderText("请输入密码");    //设置默认提示文字
    lineEdit_User_Password->setMaxLength(15);                   //设置密码长度
    lineEdit_User_Password->setEchoMode(QLineEdit::Password);   //设置为密码模式
    ui->statusBar->addWidget(lineEdit_User_Password);           //将密码输入框添加到状态栏
    pushButton_Login = new QPushButton(this);                   //新建登录按钮
    pushButton_Login->setMaximumHeight(22);                     //设置按钮最大高度
    pushButton_Login->setMinimumWidth(75);                      //设置最小宽度
    pushButton_Login->setToolTip("登录");                         //设置登录按钮帮助提示文档
    ui->statusBar->addWidget(pushButton_Login);                 //将登录按钮添加到状态栏
    connect(pushButton_Login,SIGNAL(clicked(bool)),this,SLOT(pushButton_Login_clicked()));              //连接信号槽
    pushButton_Regist = new QPushButton(this);                  //新建注册那妞
    pushButton_Regist->setMaximumHeight(22);                    //设置最大高度
    pushButton_Regist->setMinimumWidth(75);                     //设置最小宽度
    pushButton_Regist->setToolTip("新用户注册");                 //设置用户注册按钮提示文字
    ui->statusBar->addWidget(pushButton_Regist);                //将注册按钮添加到状态栏
    connect(pushButton_Regist,SIGNAL(clicked(bool)),this,SLOT(pushButton_Regist_clicked()));
    pushButton_Retrieve_Password = new QPushButton(this);       //新建找回密码按钮
    pushButton_Retrieve_Password->setMaximumHeight(22);         //设置最大高度
    pushButton_Retrieve_Password->setMinimumWidth(75);              //设置最小宽度
    pushButton_Retrieve_Password->setToolTip("找回密码");        //设置找回密码按钮提示文字
    ui->statusBar->addWidget(pushButton_Retrieve_Password);     //将找回密码按钮添加到状态栏
    connect(pushButton_Retrieve_Password,SIGNAL(clicked(bool)),this,SLOT(Retrieve_Password()));         //连接找回密码槽函数
    pushButton_set_up = new QPushButton(this);              //新建设置那妞
    pushButton_set_up->setMaximumHeight(22);                //设置按钮最大高度
    pushButton_set_up->setMinimumWidth(75);                 //设置最小宽度
    pushButton_set_up->setToolTip("系统设置");                  //设置设置按钮提示文字
    ui->statusBar->addWidget(pushButton_set_up);                //将设置按钮添加到状态栏中
    connect(pushButton_set_up,SIGNAL(clicked(bool)),this,SLOT(slot_set_up()));                  //连接设置槽函数
    pushButton_set_up->hide();
    pushButton_shop = new QPushButton(this);                    //新建商店按钮
    pushButton_shop->setMaximumHeight(22);                      //设置按钮最大高度
    pushButton_shop->setMinimumWidth(75);                       //设置最小宽度
    pushButton_shop->setToolTip("购买商品");                        //设置商店按钮提示文字
    ui->statusBar->addWidget(pushButton_shop);                      //将商店按钮添加到状态栏中
    connect(pushButton_shop,SIGNAL(clicked(bool)),this,SLOT(slot_pushbutton_shop_clicked()));             //连接商店按钮槽函数
    pushButton_Pack = new QPushButton(this);                //新建按钮
    pushButton_Pack->setMaximumHeight(22);          //设置最大高度
    pushButton_Pack->setMinimumWidth(75);               //设置最小宽度
    pushButton_Pack->setToolTip("背包");                  //设置提示信息
    ui->statusBar->addWidget(pushButton_Pack);              //将按钮添加到状态栏
    connect(pushButton_Pack,SIGNAL(clicked(bool)),this,SLOT(slot_pushbutton_pack()));           //连接槽函数
    pushButton_AboutUs = new QPushButton(this);                 //新建关于我们按钮
    pushButton_AboutUs->setMaximumHeight(22);                   //设置最大高度
    pushButton_AboutUs->setMinimumWidth(75);                    //设置最小宽度
    pushButton_AboutUs->setToolTip("关于我们");                   //设置提示信息
    ui->statusBar->addWidget(pushButton_AboutUs);               //将关于我们按钮添加到状态栏
    connect(pushButton_AboutUs,SIGNAL(clicked(bool)),this,SLOT(slot_about_us()));           //连接关于我们槽函数
    //快捷键初始化
    ui->pushButton_book->setStyleSheet("QPushButton{border-image:url(:/Main/Images/Main/book.png)}QPushButton:hover{border-image:url(:/Main/Images/Main/book_press.png)}QPushButton:pressed{border-image:url(:/Main/Images/Main/book_press1.png)}");                            //设置电子书样式表
    ui->pushButton_on_off->setStyleSheet("QPushButton{border-image:url(:/Main/Images/Main/shut_bar_nomal.png)}QPushButton:hover{border-image:url(:/Main/Images/Main/shut_bar_press.png)}QPushButton:pressed{border-image:url(:/Main/Images/Main/shut_bar.png)}");               //设置快捷键样式表
    ui->pushButton_danci->setStyleSheet("QPushButton{border-image:url(:/Main/Images/Main/danci.png)}QPushButton:hover{border-image:url(:/Main/Images/Main/danci_press.png)}QPushButton:pressed{border-image:url(:/Main/Images/Main/danci.png)}");                               //设置单词样式表
    pushButton_Login->setStyleSheet("QPushButton{border-image:url(:/Main/Images/Main/login.png)}QPushButton:hover{border-image:url(:/Main/Images/Main/loginon.png)}QPushButton:pressed{border-image:url(:/Main/Images/Main/login.png)}");                                       //设置登录按钮样式表
    pushButton_Regist->setStyleSheet("QPushButton{border-image:url(:/Main/Images/Main/regist.png)}QPushButton:hover{border-image:url(:/Main/Images/Main/registon.png)}QPushButton:pressed{border-image:url(:/Main/Images/Main/regist.png)}");                                   //设置注册按钮样式表
    pushButton_Retrieve_Password->setStyleSheet("QPushButton{border-image:url(:/Main/Images/Main/retrieve.png)}QPushButton:hover{border-image:url(:/Main/Images/Main/retrieveon.png)}QPushButton:pressed{border-image:url(:/Main/Images/Main/retrieve.png)}");                  //设置找回密码样式表
    pushButton_set_up->setStyleSheet("QPushButton{border-image:url(:/Main/Images/Main/setup.png)}QPushButton:hover{border-image:url(:/Main/Images/Main/setupon.png)}QPushButton:pressed{border-image:url(:/Main/Images/Main/setup.png)}");                                      //设置设置按钮样式表
    pushButton_shop->setStyleSheet("QPushButton{border-image:url(:/Main/Images/Main/shop.png)}QPushButton:hover{border-image:url(:/Main/Images/Main/shopon.png)}QPushButton:pressed{border-image:url(:/Main/Images/Main/shop.png)}");                                           //设置商店按钮样式表
    pushButton_AboutUs->setStyleSheet("QPushButton{border-image:url(:/Main/Images/Main/aboutme.png)}QPushButton:hover{border-image:url(:/Main/Images/Main/aboutmeon.png)}QPushButton:pressed{border-image:url(:/Main/Images/Main/aboutme.png)}");                               //设置关于我们样式表
    pushButton_Pack->setStyleSheet("QPushButton{border-image:url(:/Main/Images/Main/pack.png)}QPushButton:hover{border-image:url(:/Main/Images/Main/packon.png)}QPushButton:pressed{border-image:url(:/Main/Images/Main/pack.png)}");                                           //设置背包样式表
    lineEdit_User_Name->setStyleSheet("QLineEdit{border-image:url(:/Main/Images/Main/linbacke.png);color:white}");          //用户名输入栏设置背景
    lineEdit_User_Password->setStyleSheet("QLineEdit{border-image:url(:/Main/Images/Main/linbacke.png);color:white}");      //用户密码输入栏设置输入背景
    ui->label_life->setToolTip("生命值");
    pushButton_shop->setEnabled(false);                     //商店按钮不可点击
    ui->pushButton_book->setEnabled(false);              //电子书按钮不可点击
    ui->pushButton_danci->setEnabled(false);             //单词按钮不可点击
    pushButton_set_up->setEnabled(false);                //设置按钮不可点击
    pushButton_Pack->setEnabled(false);                          //背包按钮不可点击
    open_flag="0";
    timer = new QTimer(this);
    connect(timer,SIGNAL(timeout()),this,SLOT(user_dog_data()));
}

MainWindow::~MainWindow()
{
    delete ui;
}
/*
 * 获取鼠标坐标
 */
void MainWindow::mousePressEvent(QMouseEvent *e)
{
    last = e->globalPos();
}
/*
 * 鼠标移动坐标
 */
void MainWindow::mouseMoveEvent(QMouseEvent *e)
{
    int dx = e->globalX() - last.x();
    int dy = e->globalY() - last.y();

    last = e->globalPos();
    move(x()+dx, y()+dy);
}
/*
 * 窗口移动坐标
 */
void MainWindow::mouseReleaseEvent(QMouseEvent *e)
{
    int dx = e->globalX() - last.x();
    int dy = e->globalY() - last.y();

    move(x()+dx, y()+dy);
}

/*
 * 点击登录按钮槽函数
 */
void MainWindow::pushButton_Login_clicked()
{

    if(lineEdit_User_Name->text().isEmpty() || lineEdit_User_Password->text().isEmpty())    //判断用户名和密码是否为空
    {
        QMessageBox::warning(this,"警告","用户名或密码不能为空",QMessageBox::Yes);          //弹出警告窗口
    }
    else
    {
        QString data;
        MyHttp* myhttp=new MyHttp();
        connect(myhttp,SIGNAL(signal_requestFinished(int,bool,const QString&)), //http请求结束信号
                this,SLOT(slot_requestFinished(int,bool,const QString&)));
        data="https://api.bmob.cn/1/classes/User?where={\"user_Name\":\""+lineEdit_User_Name->text().toLatin1()+"\"}";
        myhttp->loginUserRequest(4,data);
        user_login_date.succeed_Flag = 0;                                                   //设置标志位
    }


}
/*
 * 用户点击注册按钮槽函数
 */
void MainWindow::pushButton_Regist_clicked()
{
    if(!user_regist)                                //判断是否存在
    {                                               //不存在，新建显示
        user_regist = new Dialog_Regist(this);
        connect(user_regist,SIGNAL(regist_to_server()),this,SLOT(send_regist_date_to_server()));                        //连接发送数据槽函数
        connect(user_regist,SIGNAL(compare_user_name()),this,SLOT(send_regist_compare_date()));                         //连接比较函数
        connect(user_regist,SIGNAL(set_user_name_password()),this,SLOT(set_user_name()));                               //连接设置用户名字槽函数
        user_regist->set_user_name(lineEdit_User_Name->text());                                         //输入框赋值
        user_regist->exec();
    }
    else                                            //存在，直接显示
    {
        user_regist->set_user_name(lineEdit_User_Name->text());                 //赋值操作
        user_regist->exec();
    }
}
/*
 * 将用户注册数据发送到服务器
 */
void MainWindow::send_regist_date_to_server()
{
    MyHttp* myhttp=new MyHttp();
    connect(myhttp,SIGNAL(signal_requestFinished(int,bool,const QString&)), //http请求结束信号
            this,SLOT(slot_requestFinished(int,bool,const QString&)));
    QJsonObject json;
    qDebug()<<user_regist->regist_date.userinfor.user_Password;
    json.insert("user_Name", user_regist->regist_date.userinfor.user_Name);
    json.insert("user_Password",user_regist->regist_date.userinfor.user_Password);
    json.insert("user_QQ", user_regist->regist_date.userinfor.user_QQ);
    json.insert("user_Email", user_regist->regist_date.userinfor.user_Email);
    json.insert("user_Money", user_regist->regist_date.userinfor.user_Money);
    json.insert("user_Phone", user_regist->regist_date.userinfor.user_Phone);
    QJsonDocument document;
    document.setObject(json);
    QByteArray jsonString = document.toJson(QJsonDocument::Compact);
    myhttp->registerRequest(1,"https://api.bmob.cn/1/classes/User",jsonString);
}
/*
 * 发送用户名对比数据到服务器
 */
void MainWindow::send_regist_compare_date()                                         //当用户输入完成用户名后，就将用户名单独发送到服务器，比较是否存在用户名冲突，并解析服务器返回的数据。查看比较结果
{

    QString data;
    MyHttp* myhttp=new MyHttp();
    connect(myhttp,SIGNAL(signal_requestFinished(int,bool,const QString&)), //http请求结束信号
            this,SLOT(slot_requestFinished(int,bool,const QString&)));
    qDebug()<<user_regist->regist_date.userinfor.user_Name;
    data="https://api.bmob.cn/1/classes/User?where={\"user_Name\":\""+user_regist->regist_date.userinfor.user_Name+"\"}";
    myhttp->queryregisterRequest(0,data);
}
/*
 * 当注册成功是
 * 将用户登录，自动填写
 */
void MainWindow::set_user_name()
{
    lineEdit_User_Name->setText(user_regist->regist_date.userinfor.user_Name);                      //用户名设置文字
    lineEdit_User_Password->setText(user_regist->regist_date.userinfor.user_Password);              //用户明码设置文字
}
/*
 * 找回密码槽函数
 */
void MainWindow::Retrieve_Password()
{
    if(lineEdit_User_Name->text()==""){
        QMessageBox::warning(this,"警告","请填写用户名",QMessageBox::Yes);
    }else{
        if(!Retrieve_Password_Dialog)                                       //判断是否存在
        {
            Retrieve_Password_Dialog = new Dialog_password(this);               //新建
            Retrieve_Password_Dialog->set_user_name(lineEdit_User_Name->text());        //调用赋值
            connect(Retrieve_Password_Dialog,SIGNAL(signal_send_psssinformation()),this,SLOT(slot_send_psssinformation()));             //连接槽函数
            connect(Retrieve_Password_Dialog,SIGNAL(signal_send_password()),this,SLOT(slot_send_password()));               //连接槽函数
            Retrieve_Password_Dialog->exec();       //执行
        }
        else
        {
            Retrieve_Password_Dialog->set_user_name(lineEdit_User_Name->text());            //调用赋值函数
            Retrieve_Password_Dialog->exec();               //执行
        }
    }
}
/*
 * 发送有效性验证数据到服务器
 */
void MainWindow::slot_send_psssinformation()
{
    QString data;
    MyHttp* myhttp=new MyHttp();
    connect(myhttp,SIGNAL(signal_requestFinished(int,bool,const QString&)), //http请求结束信号
            this,SLOT(slot_requestFinished(int,bool,const QString&)));
    data="https://api.bmob.cn/1/classes/User?where={\"user_Name\":\""+ Retrieve_Password_Dialog->information.user_Name+"\"}";
    myhttp->queryregisterRequest(11,data);

}
/*
 * 发送密码信息
 */
void MainWindow::slot_send_password()

{
    user.user_Password=Retrieve_Password_Dialog->user_password.user_Password;
    MyHttp* myhttp=new MyHttp();
    connect(myhttp,SIGNAL(signal_requestFinished(int,bool,const QString&)), //http请求结束信号
            this,SLOT(slot_requestFinished(int,bool,const QString&)));
    myhttp->passwordRequest(12,"https://api.bmob.cn/1/classes/User",user);
}


/*
 * 关闭按钮槽函数
 */
void MainWindow::on_pushButton_close_clicked()
{
    if(open_flag=="0")
        this->close();              //调用关闭函数
}
/*
 * 窗口最小化槽函数
 */
void MainWindow::on_pushButton_Mini_clicked()
{
    this->showMinimized();              //调用最小换函数
}
/*
 * 弹出收起快捷键栏
 */
void MainWindow::on_pushButton_on_off_clicked()
{
    if(the_flage_of_shut_pushbuyyon)                //如果弹出快捷键标志位为真
    {
        ui->widget->move(690,80);                   //快捷键移动位置
        the_flage_of_shut_pushbuyyon = false;           //款借鉴标志位取反
    }
    else
    {
        ui->widget->move(790,80);                  //快捷键移动位置
        the_flage_of_shut_pushbuyyon =true;         //快捷键标志位取反
    }
}
/*
 * 商店按钮槽函数
 */
void MainWindow::slot_pushbutton_shop_clicked()
{
    open_flag="1";
    if(!shop)
    {
        shop = new Form_Shop(this);//创建商店
        shop->move(550,200);            //移动坐标
        shop->show();               //商店显示
        connect(shop,SIGNAL(pushButton_on_clicked(int)),this,SLOT(slot_valueFinished(int)));
    }
    else
    {
        shop->show();               //商店显示
    }
}
/*
 * 电子书按钮
 */
void MainWindow::on_pushButton_book_clicked()
{
    if(!book)
    {
        book = new Book_Form(this);                 //如果电子书界面第一次使用，则新建
        book->setGeometry(0,30,690,542);            //设置界面位置及大小
        connect(book,SIGNAL(close_form()),this,SLOT(the_Book_Form_Close()));        //连接槽函数
        book->show();                               //界面显示
        ui->label_3->hide();
        connect(book,SIGNAL(book_moeny(int)),this,SLOT(slot_valueFinished(int)));
    }
    else
    {
        book->show();                       //界面显示
        ui->label_3->hide();
        book->timer->start(180000);
    }
    ui->widget->move(790,80);                  //移动位置
    the_flage_of_shut_pushbuyyon =true;             //快捷键标志位置为true
    ui->label->setStyleSheet("border-image:url(:/Main/Images/BackGround/Main_Book_back.png)");             //设置主界面背景
}
/*
 * 单词按钮按下槽函数
 */
void MainWindow::on_pushButton_danci_clicked()
{
    if(!danci)
    {
        danci = new Danci_Form(this);                   //如果单词界面第一次使用则新建
        danci->setGeometry(0,30,690,542);               //设置界面位置及大小
        connect(danci,SIGNAL(close_word()),this,SLOT(the_Word_Form_Close()));                       //连接关闭单词界面槽函数
        connect(danci,SIGNAL(word_money(int)),this,SLOT(slot_valueFinished(int)));
        danci->show();                          //界面显示
        ui->label_3->hide();
    }
    else
    {
        danci->show();                      //界面显示
        ui->label_3->hide();
    }
    ui->widget->move(790,80);                          //移动位置
    the_flage_of_shut_pushbuyyon =true;             //快捷键标志位置为true
    ui->label->setStyleSheet("border-image:url(:/Main/Images/BackGround/Main_Word_back.png)");
}
/*
 * 当关闭电子书信号触发
 */
void MainWindow::the_Book_Form_Close()
{
    ui->label_3->show();
    book->timer->stop();
    ui->label->setStyleSheet("border-image:url(:/Main/Images/BackGround/Main_back.png)");                   //设置主界面背景
}
/*
 * 关于我们槽函数
 */
void MainWindow::slot_about_us()
{
    if(!about_Us)               //如果关于我们不存在
    {
        about_Us = new Dialog_About_us(this);           //新建关于我们
        about_Us->exec();                           //关于我们显示
    }
    else
    {
        about_Us->exec();               //显示
    }
}
/*
 * 关闭单词界面槽函数
 */
void MainWindow::the_Word_Form_Close()
{
    ui->label_3->show();
    ui->label->setStyleSheet("border-image:url(:/Main/Images/BackGround/Main_back.png)");                   //设置主界面背景
}
/*
 * 背包槽函数
 */
void MainWindow::slot_pushbutton_pack()
{
    open_flag="1";
    if(!pack)
    {
        pack = new Form_back(this);             //创建背包
        pack->move(550,200);                //移动坐标
        pack->show();                   //背包显示
        connect(pack,SIGNAL(pushButton_on_clicked(int)),this,SLOT(slot_valueFinished(int)));
        //这就是该上面的数字的八个函数
        pack->change_number(1,food.food1);
        pack->change_number(2,food.food2);
        pack->change_number(3,food.food3);
        pack->change_number(4,food.food4);
        pack->change_number(5,food.food5);
        pack->change_number(6,food.food6);
        pack->change_number(7,food.food7);
        pack->change_number(8,food.food8);
    }
    else
    {
        pack->show();
        pack->change_number(1,food.food1);
        pack->change_number(2,food.food2);
        pack->change_number(3,food.food3);
        pack->change_number(4,food.food4);
        pack->change_number(5,food.food5);
        pack->change_number(6,food.food6);
        pack->change_number(7,food.food7);
        pack->change_number(8,food.food8);
    }
}

void MainWindow::play_Dog_Move(int temp)
{
    switch (temp) {
    case 0:
    {
        if(dog_Movie)
        {
            dog_Movie->stop();
            dog_Movie->setFileName(":/Dog/Images/Dog/Dog_1.gif");
            ui->label_3->setMovie(dog_Movie);
            dog_Movie->start();
        }
        else
        {
            dog_Movie = new QMovie();
            dog_Movie->setFileName(":/Dog/Images/Dog/Dog_1.gif");
            ui->label_3->setMovie(dog_Movie);
            dog_Movie->start();
        }
        break;
    }
    case 1:
    {
        if(dog_Movie)
        {
            dog_Movie->stop();
            dog_Movie->setFileName(":/Dog/Images/Dog/Dog_2.gif");
            ui->label_3->setMovie(dog_Movie);
            dog_Movie->start();
        }
        else
        {
            dog_Movie = new QMovie();
            dog_Movie->setFileName(":/Dog/Images/Dog/Dog_2.gif");
            ui->label_3->setMovie(dog_Movie);
            dog_Movie->start();
        }
        break;
    }
        break;
    case 2:
    {
        if(dog_Movie)
        {
            dog_Movie->stop();
            dog_Movie->setFileName(":/Dog/Images/Dog/Dog_3.gif");
            ui->label_3->setMovie(dog_Movie);
            dog_Movie->start();
        }
        else
        {
            dog_Movie = new QMovie();
            dog_Movie->setFileName(":/Dog/Images/Dog/Dog_3.gif");
            ui->label_3->setMovie(dog_Movie);
            dog_Movie->start();
        }
        break;
    }
        break;
    default:
        break;
    }
}
/*
 * 更改生命值
 * life_number   0-125
 */
void MainWindow::set_Life(int life_number)
{

    ui->label_life_1->move((90+((100-life_number)/2)),0);                //生命值显示
    ui->label_life->setToolTip(QString::number(life_number,10));
    qDebug()<<life_number;
}
/*
 * 设置能量值
 */
void MainWindow::set_Eng(int Eng)
{
    ui->label_4->setText(QString::number(Eng,10));
}
/*
 * 设置奢侈度
 */
void MainWindow::set_Shechi(int She)
{
    ui->label_5->setText(QString::number(She,10));

}
/*
 * 设置金币数量
 */
void MainWindow::set_Coin(QString Coin)
{
    ui->label_6->setText(Coin);
}
void MainWindow::slot_requestFinished(int flag,bool bSuccess, const QString &strResult)
{
    switch (flag) {
    case 0:
    {
        if(bSuccess)
        {
            qDebug()<<strResult;
            QJsonParseError json_error;
            QJsonDocument parse_doucment = QJsonDocument::fromJson(strResult.toLatin1(), &json_error);
            if(json_error.error == QJsonParseError::NoError)
            {
                if(parse_doucment.isObject())
                {
                    QJsonObject obj = parse_doucment.object();
                    QJsonValue arry=obj.take("results");
                    QString name = arry.toString();
                    if(arry.toArray().size()!=0)
                    {
                        user_regist->message_1();
                    }
                }

            }
            //  ui->resultEdit->setPlainText(strResult); //纯文本显示
        }
        else
        {
            user_regist->message_3();
            qDebug()<<strResult;
            //  ui->resultEdit->setPlainText(tr("请求失败！"));

        }
        break;
    }
    case 1:
        if(bSuccess)
        {
            qDebug()<<strResult;
            MyHttp* myhttp=new MyHttp();
            connect(myhttp,SIGNAL(signal_requestFinished(int,bool,const QString&)), //http请求结束信号
                    this,SLOT(slot_requestFinished(int,bool,const QString&)));

            QJsonObject json;
            json.insert("dog_Name", user_regist->regist_date.doginfor.dog_Name);
            json.insert("dog_Type",user_regist->regist_date.doginfor.dog_Type);
            json.insert("dog_Energy", user_regist->regist_date.doginfor.dog_Energy);
            json.insert("dog_Age", user_regist->regist_date.doginfor.dog_Age);
            json.insert("dog_Health", user_regist->regist_date.doginfor.dog_Health);
            json.insert("dog_Wasteful", user_regist->regist_date.doginfor.dog_Wasteful);
            json.insert("user_Name", user_regist->regist_date.userinfor.user_Name);


            QJsonDocument document;
            document.setObject(json);
            QByteArray jsonString = document.toJson(QJsonDocument::Compact);
            myhttp->registerDogRequest(2,"https://api.bmob.cn/1/classes/Dog",jsonString);

        }
        else
        {
            user_regist->message_3();
            qDebug()<<strResult;
            //  ui->resultEdit->setPlainText(tr("请求失败！"));

        }
        break;
    case 2:
        if(bSuccess)
        {
            qDebug()<<strResult;
            QString data;
            MyHttp* myhttp=new MyHttp();
            connect(myhttp,SIGNAL(signal_requestFinished(int,bool,const QString&)), //http请求结束信号
                    this,SLOT(slot_requestFinished(int,bool,const QString&)));
            data="{\"food_one\":0,\"food_two\":0,\"food_three\":0"
                 ",\"food_four\":0,\"food_five\":0,\"food_six\":0"
                 ",\"food_seven\":0,\"food_eight\":0,\"user_Name\":\""
                    +user_regist->regist_date.userinfor.user_Name+"\"}";
            myhttp->registerFoodRequest(3,"https://api.bmob.cn/1/classes/Food",data);

        }
        else
        {
            user_regist->message_3();
            qDebug()<<strResult;
            //  ui->resultEdit->setPlainText(tr("请求失败！"));

        }
        break;
    case 3:
        if(bSuccess)
        {
            user_regist->message_2();

        }
        else
        {
            user_regist->message_3();
            qDebug()<<strResult;

        }
        break;
    case 4:
        if(bSuccess)
        {
            qDebug()<<strResult;
            QJsonParseError json_error;
            QJsonDocument parse_doucment = QJsonDocument::fromJson(strResult.toLatin1(), &json_error);
            if(json_error.error == QJsonParseError::NoError)
            {
                if(parse_doucment.isObject())
                {
                    QJsonObject obj = parse_doucment.object();
                    QJsonValue arry=obj.take("results");
                    QJsonArray array=arry.toArray();
                    if(arry.toArray().size()==0)
                    {
                        QMessageBox::warning(this,"警告","无此用户",QMessageBox::Yes);
                    }else{


                        QJsonValue value = array.at(0);
                        QJsonObject object=value.toObject();
                        if(object.take("user_Password").toString()==lineEdit_User_Password->text())
                        {
                            user.user_Name=object.take("user_Name").toString();
                            user.user_Id=object.take("objectId").toString();
                            user.user_Password=object.take("user_Password").toString();
                            user.Money=object.take("user_Money").toString();
                            QString data;
                            MyHttp* myhttp=new MyHttp();
                            connect(myhttp,SIGNAL(signal_requestFinished(int,bool,const QString&)), //http请求结束信号
                                    this,SLOT(slot_requestFinished(int,bool,const QString&)));
                            data="https://api.bmob.cn/1/classes/Dog?where={\"user_Name\":\""+lineEdit_User_Name->text().toLatin1()+"\"}";
                            myhttp->loginDogRequest(5,data);
                        }else{
                            QMessageBox::warning(this,"警告","密码错误",QMessageBox::Yes);
                        }
                    }
                }
            }
        }
        else
        {
            QMessageBox::warning(this,"警告","登录失败",QMessageBox::Yes);
            qDebug()<<strResult;

        }
        break;
    case 5:
        if(bSuccess)
        {
            qDebug()<<strResult;
            QJsonParseError json_error;
            QJsonDocument parse_doucment = QJsonDocument::fromJson(strResult.toLatin1(), &json_error);
            if(json_error.error == QJsonParseError::NoError)
            {
                if(parse_doucment.isObject())
                {
                    QJsonObject obj = parse_doucment.object();
                    QJsonValue arry=obj.take("results");
                    QJsonArray array=arry.toArray();
                    if(arry.toArray().size()==0)
                    {
                        QMessageBox::warning(this,"警告","无此用户",QMessageBox::Yes);
                    }else{


                        QJsonValue value = array.at(0);
                        QJsonObject object=value.toObject();
                        dog.dog_Name=object.take("dog_Name").toString();
                        dog.dog_Id=object.take("objectId").toString();
                        dog.dog_Energy=object.take("dog_Energy").toVariant().toInt();
                        dog.dog_Type=object.take("dog_Type").toVariant().toInt();
                        dog.dog_Health=object.take("dog_Health").toVariant().toInt();
                        dog.dog_Age=object.take("dog_Age").toVariant().toInt();
                        dog.dog_Wasteful=object.take("dog_Wasteful").toVariant().toInt();
                        QString data;
                        MyHttp* myhttp=new MyHttp();
                        connect(myhttp,SIGNAL(signal_requestFinished(int,bool,const QString&)), //http请求结束信号
                                this,SLOT(slot_requestFinished(int,bool,const QString&)));
                        data="https://api.bmob.cn/1/classes/Food?where={\"user_Name\":\""+lineEdit_User_Name->text().toLatin1()+"\"}";
                        myhttp->loginUserRequest(6,data);
                    }
                }
            }
        }
        else
        {
            QMessageBox::warning(this,"警告","登录失败",QMessageBox::Yes);
            qDebug()<<strResult;

        }
        break;
    case 6:
        if(bSuccess)
        {
            qDebug()<<strResult;
            QJsonParseError json_error;
            QJsonDocument parse_doucment = QJsonDocument::fromJson(strResult.toLatin1(), &json_error);
            if(json_error.error == QJsonParseError::NoError)
            {
                if(parse_doucment.isObject())
                {
                    QJsonObject obj = parse_doucment.object();
                    QJsonValue arry=obj.take("results");
                    QJsonArray array=arry.toArray();
                    if(arry.toArray().size()==0)
                    {
                        QMessageBox::warning(this,"警告","无此用户",QMessageBox::Yes);
                    }else{



                        QJsonValue value = array.at(0);
                        QJsonObject object=value.toObject();
                        food.food_Id=object.take("objectId").toString();
                        food.food1=object.take("food_one").toVariant().toInt();
                        food.food2=object.take("food_two").toVariant().toInt();
                        food.food3=object.take("food_three").toVariant().toInt();
                        food.food4=object.take("food_four").toVariant().toInt();
                        food.food5=object.take("food_five").toVariant().toInt();
                        food.food6=object.take("food_six").toVariant().toInt();
                        food.food7=object.take("food_seven").toVariant().toInt();
                        food.food8=object.take("food_eight").toVariant().toInt();
                        play_Dog_Move(dog.dog_Type);
                        set_Life(dog.dog_Health);
                        set_Eng(dog.dog_Energy);
                        set_Shechi(dog.dog_Wasteful);
                        set_Coin(user.Money);
                        pushButton_Retrieve_Password->setEnabled(false);
                        pushButton_shop->setEnabled(true);                     //激活商店按钮
                        ui->pushButton_book->setEnabled(true);              //激活电子书按钮
                        ui->pushButton_danci->setEnabled(true);             //激活单词按钮
                        pushButton_set_up->setEnabled(true);                //激活设置按钮
                        pushButton_Pack->setEnabled(true);                          //背包按钮激活
                        timer->start(180000);

                    }
                }
            }
        }
        else
        {
            QMessageBox::warning(this,"警告","登录失败",QMessageBox::Yes);
            qDebug()<<strResult;

        }
        break;
    case 7:
        if(bSuccess)
        {
            qDebug()<<strResult;
            food1=0;
            food2=0;food3=0;food4=0;food5=0;food6=0;food7=0;food6=0;
        }
        else
        {
            qDebug()<<strResult;
            if(strResult=="timeout"){
                food.food1=food.food1-food1;
                food.food2=food.food2-food2;
                food.food3=food.food3-food3;
                food.food4=food.food4-food4;
                food.food5=food.food5-food5;
                food.food6=food.food6-food6;
                food.food7=food.food7-food7;
                food.food8=food.food8-food8;
                food1=0;
                food2=0;food3=0;food4=0;food5=0;food6=0;food7=0;food6=0;
            }

        }
        break;
    case 8:
        if(bSuccess)
        {
            qDebug()<<strResult;
            food1=0;
            food2=0;food3=0;food4=0;food5=0;food6=0;food7=0;food6=0;
            if(dog.dog_Health<125){
                dog.dog_Health=dog.dog_Health+1;
            }else{
                dog.dog_Health=125;
            }
            if(dog.dog_Energy<100){
                dog.dog_Energy= dog.dog_Energy+1;
            }else{
                dog.dog_Energy=100;
            }

            set_Life(dog.dog_Health);
            set_Eng(dog.dog_Energy);
            MyHttp* myhttp=new MyHttp();
            connect(myhttp,SIGNAL(signal_requestFinished(int,bool,const QString&)), //http请求结束信号
                    this,SLOT(slot_requestFinished(int,bool,const QString&)));
            myhttp->upDogRequest(10,"https://api.bmob.cn/1/classes/Dog",dog);
        }
        else
        {
            qDebug()<<strResult;
            if(strResult=="timeout"){
                food.food1=food.food1-food1;
                food.food2=food.food2-food2;
                food.food3=food.food3-food3;
                food.food4=food.food4-food4;
                food.food5=food.food5-food5;
                food.food6=food.food6-food6;
                food.food7=food.food7-food7;
                food.food8=food.food8-food8;
                food1=0;
                food2=0;food3=0;food4=0;food5=0;food6=0;food7=0;food6=0;
            }

        }
        break;
    case 9:
        if(bSuccess)
        {
            qDebug()<<strResult;
            money=0;
            set_Coin(user.Money);
        }
        else
        {
            if(strResult=="timeout"){
                user.Money=QString::number(user.Money.toInt()-money);
                money=0;
            }
            qDebug()<<strResult;

        }
        break;
    case 10:
        if(bSuccess)
        {
            qDebug()<<strResult;
        }
        else
        {
            qDebug()<<strResult;

        }
        break;
    case 11:
    {
        if(bSuccess)
        {
            qDebug()<<strResult;
            QJsonParseError json_error;
            QJsonDocument parse_doucment = QJsonDocument::fromJson(strResult.toLatin1(), &json_error);
            if(json_error.error == QJsonParseError::NoError)
            {
                if(parse_doucment.isObject())
                {
                    QJsonObject obj = parse_doucment.object();
                    QJsonValue arry=obj.take("results");
                    QJsonArray array=arry.toArray();
                    if(array.size()==0)
                    {
                        QMessageBox::warning(this,"警告","无此用户",QMessageBox::Yes);
                    }else{


                        QJsonValue value = array.at(0);
                        QJsonObject object=value.toObject();
                        if(object.take("user_Email").toString()!=Retrieve_Password_Dialog->information.user_Email)
                        {
                            Retrieve_Password_Dialog->message_1();
                            break;
                        }
                        if(object.take("user_Phone").toString()!=Retrieve_Password_Dialog->information.user_Phone){
                            Retrieve_Password_Dialog->message_2();
                            break;
                        }
                        if(object.take("user_QQ").toString()!=Retrieve_Password_Dialog->information.user_QQ){
                            Retrieve_Password_Dialog->message_3();
                            break;
                        }

                        user.user_Id=object.take("objectId").toString();
                        QMessageBox::warning(this,"警告","验证成功",QMessageBox::Yes);
                        Retrieve_Password_Dialog->next_do();

                    }


                }

            }

        }
        else
        {
            qDebug()<<strResult;


        }
        break;

    }
    case 12:
        if(bSuccess)
        {
            Retrieve_Password_Dialog->message_4();
            qDebug()<<strResult;
        }
        else
        {
            Retrieve_Password_Dialog->message_5();
            qDebug()<<strResult;

        }
        break;
    default:
        break;
    }


}
void MainWindow::update()
{
    dog_Movie->stop();
    dog_Movie->setFileName(":/Dog/Images/Dog/Dog_1.gif");
    ui->label_3->setMovie(dog_Movie);
    dog_Movie->start();
            qDebug()<<"背包按钮1111111";
//    time->stop();

}
void MainWindow::slot_valueFinished(int flag)
{

    MyHttp* myhttp;
    int m;
    switch (flag) {
    case 1:
    {
        qDebug()<<"背包按钮1";

        if(food.food1>0){
            food.food1--;
            food1--;
            pack->change_number(1,food.food1);


            //实现喂养成功，宠物高兴动画
            QTimer *tim = new QTimer(this);
            tim->setSingleShot(true);
            connect(tim, SIGNAL(timeout()), this, SLOT(update()));
            tim->start(1000);
            dog_Movie->stop();
            dog_Movie->setFileName(":/Dog/Images/Dog/Dog_1_feed.gif");//喂养成功动画
            ui->label_3->setMovie(dog_Movie);
            dog_Movie->start();
            qDebug()<<"背包按钮11234";


        }
        else
            QMessageBox::warning(this,"敬告","当前物品已用完\n请前往商店够买！",QMessageBox::Yes);
        break;
    }
    case 2:
    {
        qDebug()<<"背包按钮2";

        if(food.food2>0){
            food.food2--;
            food2--;
            pack->change_number(2,food.food2);

            //实现喂养成功，宠物高兴动画
            QTimer *tim = new QTimer(this);
            tim->setSingleShot(true);
            connect(tim, SIGNAL(timeout()), this, SLOT(update()));
            tim->start(1000);
            dog_Movie->stop();
            dog_Movie->setFileName(":/Dog/Images/Dog/Dog_1_feed.gif");//喂养成功动画
            ui->label_3->setMovie(dog_Movie);
            dog_Movie->start();
            qDebug()<<"背包按钮11234";


        }
        else
            QMessageBox::warning(this,"敬告","当前物品已用完\n请前往商店够买！",QMessageBox::Yes);
        break;
    }
    case 3:
    {
        qDebug()<<"背包按钮3";

        if(food.food3>0){
            food.food3--;
            food3--;
            pack->change_number(3,food.food3);


            //实现喂养成功，宠物高兴动画
            QTimer *tim = new QTimer(this);
            tim->setSingleShot(true);
            connect(tim, SIGNAL(timeout()), this, SLOT(update()));
            tim->start(1000);
            dog_Movie->stop();
            dog_Movie->setFileName(":/Dog/Images/Dog/Dog_1_feed.gif");//喂养成功动画
            ui->label_3->setMovie(dog_Movie);
            dog_Movie->start();
            qDebug()<<"背包按钮11234";

        }
        else
            QMessageBox::warning(this,"敬告","当前物品已用完\n请前往商店够买！",QMessageBox::Yes);
        break;
    }
    case 4:
    {
        qDebug()<<"背包按钮4";

        if(food.food4>0){
            food.food4--;
            food4--;
            pack->change_number(4,food.food4);
            //实现喂养成功，宠物高兴动画
            QTimer *tim = new QTimer(this);
            tim->setSingleShot(true);
            connect(tim, SIGNAL(timeout()), this, SLOT(update()));
            tim->start(1000);
            dog_Movie->stop();
            dog_Movie->setFileName(":/Dog/Images/Dog/Dog_1_feed.gif");//喂养成功动画
            ui->label_3->setMovie(dog_Movie);
            dog_Movie->start();
            qDebug()<<"背包按钮11234";
        }
        else
            QMessageBox::warning(this,"敬告","当前物品已用完\n请前往商店够买！",QMessageBox::Yes);
        break;
    }
    case 5:
    {
        qDebug()<<"背包按钮5";

        if(food.food5>0){
            food.food5--;
            food5--;
            pack->change_number(5,food.food5);

            //实现喂养成功，宠物高兴动画
            QTimer *tim = new QTimer(this);
            tim->setSingleShot(true);
            connect(tim, SIGNAL(timeout()), this, SLOT(update()));
            tim->start(1000);
            dog_Movie->stop();
            dog_Movie->setFileName(":/Dog/Images/Dog/Dog_1_feed.gif");//喂养成功动画
            ui->label_3->setMovie(dog_Movie);
            dog_Movie->start();
            qDebug()<<"背包按钮11234";

        }
        else
            QMessageBox::warning(this,"敬告","当前物品已用完\n请前往商店够买！",QMessageBox::Yes);
        break;
    }
    case 6:
    {
        qDebug()<<"背包按钮6";

        if(food.food6>0){
            food.food6--;
            food6--;
            pack->change_number(6,food.food6);

            //实现喂养成功，宠物高兴动画
            QTimer *tim = new QTimer(this);
            tim->setSingleShot(true);
            connect(tim, SIGNAL(timeout()), this, SLOT(update()));
            tim->start(1000);
            dog_Movie->stop();
            dog_Movie->setFileName(":/Dog/Images/Dog/Dog_1_feed.gif");//喂养成功动画
            ui->label_3->setMovie(dog_Movie);
            dog_Movie->start();
            qDebug()<<"背包按钮11234";


        }
        else
            QMessageBox::warning(this,"敬告","当前物品已用完\n请前往商店够买！",QMessageBox::Yes);
        break;
    }
    case 7:
    {
        qDebug()<<"背包按钮7";

        if(food.food7>0){
            food.food7--;
            food7--;
            pack->change_number(7,food.food7);

            //实现喂养成功，宠物高兴动画
            QTimer *tim = new QTimer(this);
            tim->setSingleShot(true);
            connect(tim, SIGNAL(timeout()), this, SLOT(update()));
            tim->start(1000);
            dog_Movie->stop();
            dog_Movie->setFileName(":/Dog/Images/Dog/Dog_1_feed.gif");//喂养成功动画
            ui->label_3->setMovie(dog_Movie);
            dog_Movie->start();
            qDebug()<<"背包按钮11234";



        }
        else
            QMessageBox::warning(this,"敬告","当前物品已用完\n请前往商店够买！",QMessageBox::Yes);
        break;
    }
    case 8:
    {
        qDebug()<<"背包按钮8";

        if(food.food8>0){
            food.food8--;
            food8--;
            pack->change_number(8,food.food8);

            //实现喂养成功，宠物高兴动画
            QTimer *tim = new QTimer(this);
            tim->setSingleShot(true);
            connect(tim, SIGNAL(timeout()), this, SLOT(update()));
            tim->start(1000);
            dog_Movie->stop();
            dog_Movie->setFileName(":/Dog/Images/Dog/Dog_1_feed.gif");//喂养成功动画
            ui->label_3->setMovie(dog_Movie);
            dog_Movie->start();
            qDebug()<<"背包按钮11234";



        }
        else
            QMessageBox::warning(this,"敬告","当前物品已用完\n请前往商店够买！",QMessageBox::Yes);
        break;
    }
    case 9:
    {
        open_flag="0";
        myhttp=new MyHttp();
        connect(myhttp,SIGNAL(signal_requestFinished(int,bool,const QString&)), //http请求结束信号
                this,SLOT(slot_requestFinished(int,bool,const QString&)));
        myhttp->upFoodRequest(8,"https://api.bmob.cn/1/classes/Food",food);
        break;
    }
    case 11:
    {
        qDebug()<<"商店按钮1";
        food.food1++;
        food1++;
        int m=user.Money.toInt()-1;
        money--;
        user.Money=QString::number(m);
        qDebug()<<user.Money;
        // pack->change_number(1,food.food1);
        break;
    }
    case 12:
    {
        qDebug()<<"商店按钮2";
        food.food2++;
        food2++;
        money--;
        int m=user.Money.toInt()-1;
        user.Money=QString::number(m);
        //  pack->change_number(2,food.food2);
        break;
    }
    case 13:
    {
        qDebug()<<"商店按钮3";
        food.food3++;
        food3++;
        money--;
        int m=user.Money.toInt()-1;
        user.Money=QString::number(m);
        // pack->change_number(3,food.food3);
        break;
    }
    case 14:
    {
        qDebug()<<"商店按钮4";
        food.food4++;
        food4++;
        money--;
        int m=user.Money.toInt()-1;
        user.Money=QString::number(m);
        // pack->change_number(4,food.food4);
        break;
    }
    case 15:
    {
        qDebug()<<"商店按钮5";
        food.food5++;
        food5++;
        money--;
        int m=user.Money.toInt()-1;
        user.Money=QString::number(m);
        //pack->change_number(5,food.food5);
        break;
    }
    case 16:
    {
        qDebug()<<"商店按钮6";
        food.food6++;
        food6++;
        money--;
        int m=user.Money.toInt()-1;
        user.Money=QString::number(m);
        // pack->change_number(6,food.food6);
        break;
    }
    case 17:
    {
        qDebug()<<"商店按钮7";
        food.food7++;
        food7++;
        money--;
        int m=user.Money.toInt()-1;
        user.Money=QString::number(m);
        //pack->change_number(7,food.food7);
        break;
    }
    case 18:
    {
        qDebug()<<"商店按钮8";
        food.food8++;
        food8++;
        money--;
        m=user.Money.toInt()-1;
        user.Money=QString::number(m);
        //pack->change_number(8,food.food8);
        break;
    }
    case 19:
    {
        open_flag="0";
        myhttp=new MyHttp();
        connect(myhttp,SIGNAL(signal_requestFinished(int,bool,const QString&)), //http请求结束信号
                this,SLOT(slot_requestFinished(int,bool,const QString&)));
        myhttp->upFoodRequest(7,"https://api.bmob.cn/1/classes/Food",food);
        myhttp->upUserRequest(9,"https://api.bmob.cn/1/classes/User",user);
        break;
    }




    case 21:
        qDebug()<<"看书三分钟，金币+1";
        m=user.Money.toInt()+1;
        user.Money=QString::number(m);
        myhttp=new MyHttp();
        connect(myhttp,SIGNAL(signal_requestFinished(int,bool,const QString&)), //http请求结束信号
                this,SLOT(slot_requestFinished(int,bool,const QString&)));
        myhttp->upUserRequest(9,"https://api.bmob.cn/1/classes/User",user);
        break;
    case 31:
        qDebug()<<"背单词，金币+1";
        m=user.Money.toInt()+1;
        user.Money=QString::number(m);
        myhttp=new MyHttp();
        connect(myhttp,SIGNAL(signal_requestFinished(int,bool,const QString&)), //http请求结束信号
                this,SLOT(slot_requestFinished(int,bool,const QString&)));
        myhttp->upUserRequest(9,"https://api.bmob.cn/1/classes/User",user);
        break;
    default:
        break;
    }
}
void MainWindow::user_dog_data()
{
    dog.dog_Health=dog.dog_Health-1;
    dog.dog_Energy= dog.dog_Energy-1;
    set_Life(dog.dog_Health);

    set_Eng(dog.dog_Energy);
    MyHttp* myhttp=new MyHttp();
    connect(myhttp,SIGNAL(signal_requestFinished(int,bool,const QString&)), //http请求结束信号
            this,SLOT(slot_requestFinished(int,bool,const QString&)));
    myhttp->upDogRequest(10,"https://api.bmob.cn/1/classes/Dog",dog);
}


void MainWindow::on_pushButton_on_off_clicked(bool checked)
{

}
